#ifndef FILESYSTEM_H_
#define FILESYSTEM_H_

#include "../lowLevel/DiskServices.h"
#include "DirectoryEntry.h"
#include <string>
#include <vector>
#include <cstdlib>

using namespace std;

class FileSystem {

private:
	DiskServices diskServices;
	int blockSize;
	int getInodeNumFromBuffer(const unsigned char* buffer, int offset);
	void getFileNameFromBuffer(const unsigned char* buffer,char* fileName, int offset);
	void resetBlockContent(unsigned char* buffer);

public:
	FileSystem();
	FileSystem(int diskSizeInBytes, int dataBlockSize, int numberOfInodes);
	virtual ~FileSystem();
	int createFile(string flag);
	int createDir ();
	char getFileType(int inode);
	int getFileSize(int inode);
	int f_read (int inode, unsigned char *buffer, int offset, int nBytes);
	int f_write (int inode, unsigned char *buffer, int offset, int nBytes);
	vector<DirectoryEntry*> d_read (int inode);
	void d_write (int inode, vector<DirectoryEntry*> filesList);
	void f_delete (int inode);
	void d_delete (int inode);
	void incInodeHardLinks(int inode);
	void decInodeHardLinks(int inode);
	void main();
};

#endif /* FILESYSTEM_H_ */
